import request from 'umi-request';

export async function saveMachine(params: any) {
  params.id = parseInt(params.id||'0')
  params.port = parseInt(params.port||'22')
  return request('/api/machine/save', {
    method: 'POST',
    data: params,
  });
}

export async function machineList(params: any) {
    params.page = params.current;
    params.limit = params.pageSize;
    delete params.current;
    delete params.pageSize;
    const res = await request('/api/machine/list', {
      method: 'POST',
      params: params,
    })
    let data = res.results
    res.data = data;
    res.total = res.len;
    return res
}

export async function getMachine(params: any) {
    return request('/api/machine/get', {
      method: 'POST',
      params: params,
    });
}
  
export async function delMachine(params: any) {
    return request('/api/machine/del', {
      method: 'POST',
      data: params,
    });
}